﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
using DECOR.BL.BE;
using DECOR.BL.BC;

namespace DECOR.WS
{
    /// <summary>
    /// Summary description for ParametroWS
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class ParametroWS : System.Web.Services.WebService
    {

        [WebMethod(EnableSession = true)]
        public DataDDLBE getDataDDL()
        {
            DataDDLBE dataDDLBE = null;

            try
            {

                if (Session["dataDDLBE"] != null)
                { dataDDLBE = (DataDDLBE)Session["dataDDLBE"]; }
                else
                {
                    Session.Timeout = 5;
                    dataDDLBE = datos();
                    Session.Add("dataDDLBE", dataDDLBE);
                }
            }
            catch
            {

            }

            return dataDDLBE;
        }

        private DataDDLBE datos()
        {



            DataDDLBE dataDDLBE = new DataDDLBE();
            List<GenericBE> lstZipCodes = new List<GenericBE>();
            List<GenericBE> lstAsesores = new List<GenericBE>();
            List<GenericBE> lstBloEnt = new List<GenericBE>();
            List<GenericBE> lstBloFac = new List<GenericBE>();
            List<GenericBE> lstCondExp = new List<GenericBE>();
            List<GenericBE> lstGrpCond = new List<GenericBE>();
            List<GenericBE> lstGrpVend = new List<GenericBE>();
            List<GenericBE> lstMotPed = new List<GenericBE>();
            List<GenericBE> lstOfVtas = new List<GenericBE>();
            List<GenericBE> lstSectores = new List<GenericBE>();
            List<GenericBE> lstTipoDoc = new List<GenericBE>();
            List<GenericBE> lstTipoVisita = new List<GenericBE>();
            try
            {

                //------------------------------------------------------------------
                ParametroBC.Instance.getDataDDL(ref lstZipCodes, ref lstAsesores, ref lstBloEnt, ref  lstBloFac, ref  lstCondExp, ref lstGrpCond,
                                                ref  lstGrpVend, ref lstMotPed, ref lstOfVtas, ref  lstSectores, ref  lstTipoDoc, ref lstTipoVisita);

                //---------------------------------------------------
                dataDDLBE.LstZipCodes = lstZipCodes;
                dataDDLBE.LstAsesores = lstAsesores;
                dataDDLBE.LstBloEnt = lstBloEnt;
                dataDDLBE.LstBloFac = lstBloFac;
                dataDDLBE.LstCondExp = lstCondExp;
                dataDDLBE.LstGrpCond = lstGrpCond;
                dataDDLBE.LstGrpVend = lstGrpVend;
                dataDDLBE.LstMotPed = lstMotPed;
                dataDDLBE.LstOfVtas = lstOfVtas;
                dataDDLBE.LstSectores = lstSectores;
                dataDDLBE.LstTipoDoc = lstTipoDoc;
                dataDDLBE.LstTipoVisita = lstTipoVisita;


            }
            catch (Exception e)
            {
                GenericBE g = new GenericBE();
                g.Descripcion = e.Message.ToString();
                dataDDLBE.LstAsesores = new List<GenericBE>();
                dataDDLBE.LstAsesores.Add(g);
                Session.Remove("dataDDLBE");
            }
            return dataDDLBE;
        }

        //rgutierrez 24.01.2012 Solo de pruebas. Eliminar
        [WebMethod()]
        public string guarda(string CCCCODCIA, string CCCCODSUC, string CCCNUMCOT)
        {
            string res = "x";
            return res;
        }
    }
}
